(function () {
	new Vue({
		el: '#contractConfig',
		data() {
			return {
				rentList: [],
				rent_count: '',
				selectedData: [],
				isEntry: false,
				quanxian: JSON.parse(localStorage.getItem('permissions')),

				options: [],
				options1: [{
					name: '是',
					code: 'Y'
				}, {
					name: '否',
					code: 'N'
				}],
				selected: [],
				selectedObj: '',
				selected1: [],

				isBreakFlag: false,
				breakPriceList: [],
				selectBreakPrice: [],
				selectBreakPriceObj: [],

				yzjFlag: false,
				yzjList: [],
				selectedYZJ: [],
				selectYZJObj:{}
			}
		},
		methods: {
			// 破底价展示
			breakPriceFun() {
				this.isBreakFlag = !this.isBreakFlag
				if (!this.isBreakFlag) return
				this.getBreakPrice()
				this.getSelectBreakPrice()
			},
			// 获取破底价配置
			getBreakPrice() {
				hlhttp.get({
					url: 'configure/dict',
					data: {
						module_code: 'CIWU',
						config_name: 'CW_BREAK_PRICE_REMINDER_TYPE',
					},
					success: res => {
						res.map(item => {
							item.name = item.dictName
							item.code = item.dictCode
						})
						this.breakPriceList = res
					}
				})
			},
			//获取选中的破底价
			getSelectBreakPrice() {
				hlhttp.get({
					url: 'configure/dict',
					data: {
						module_code: 'CIWU',
						config_name: 'CW_BREAK_PRICE_REMINDER_TYPE_CONFIG',
					},
					success: res => {
						this.selectBreakPrice = [res[0].dictValue]
						this.selectBreakPriceObj = res[0]
					}
				})
			},
			// 选中的破底价
			selectBreakPriceFun(val) {
				console.log(val)
				let data = {
					module_code: 'CIWU',
					config_name: 'CW_BREAK_PRICE_REMINDER_TYPE_CONFIG',
					dict_code: this.selectBreakPriceObj.dictCode,
					dict_name: val[0].dictName,
					dict_value: val[0].dictCode,
					dict_display_name: this.selectBreakPriceObj.dictDisplayName || '#',
					dict_property: this.selectBreakPriceObj.dictProperty || '#',
					default_flag: this.selectBreakPriceObj.defaultFlag || '#',
					config_type: this.selectBreakPriceObj.configType || '#',
				}
				hlhttp.put({
					url: 'configure/tenant_dict_config',
					data: data,
					success: res => {}
				})
			},


			// 获取意向工作流配置
			geTintentBpmConfig() {
				hlhttp.get({
					url: 'configure/intent_bpm_config/dict',
					success: res => {
						this.selected1 = [res.open_flag]
					}
				})
			},

			selectTintentBpmConfig() {
				hlhttp.put({
					url: 'configure/intent_bpm_config/dict',
					data: {
						open_flag: this.selected1 + ''
					},
					success: res => {}
				})
			},
			// 获取意向金抵扣配置
			getTintentConfig() {
				hlhttp.get({
					url: 'configure/dict',
					data: {
						module_code: 'YIXA',
						config_name: 'YX_INTENT_CASH_DEDUCTION_TYPE',
					},
					success: res => {
						res.map(item => {
							item.code = item.dictCode
							item.name = item.dictName
						})
						this.options = res
					}
				})
			},
			selectTintentConfig() {
				hlhttp.get({
					url: 'configure/dict',
					data: {
						module_code: 'YIXA',
						config_name: 'YX_INTENT_CASH_DEDUCTION_TYPE_CONFIG',
					},
					success: res => {
						this.selected = [res[0].dictValue]
						this.selectedObj = res[0]
					}
				})
			},

			switchTintentConfig(val) {
				console.log(val)
				let data = {
					module_code: 'YIXA',
					config_name: 'YX_INTENT_CASH_DEDUCTION_TYPE_CONFIG',
					dict_code: this.selectedObj.dictCode,
					dict_name: this.selectedObj.dictName,
					dict_value: val[0].dictCode,
					dict_display_name: this.selectedObj.dictDisplayName || '#',
					dict_property: this.selectedObj.dictProperty || '#',
					default_flag: this.selectedObj.defaultFlag || '#',
					config_type: this.selectedObj.configType || '#',
				}
				hlhttp.put({
					url: 'configure/tenant_dict_config',
					data: data,
					success: res => {}
				})
			},




			goToCustom() {
				hlUrlUtil.goTo('lcCutomFields', {
					ddtab: true,
					module: 'CONTRACT'
				})
			},
			//获取租金计算周期字典
			getRent() {
				var that = this
				hlhttp.get({
					url: 'configure/dict',
					data: {
						module_code: 'CIWU',
						config_name: 'CW_RENT_CALCULATE_PERIOD_TYPE',
					},
					success: function (res) {
						res.map(item => {
							item.name = item.dictName
							item.code = item.dictCode
						})
						that.rentList = res
					}
				})
			},
			// 选中的租金计算周期字典
			getSelectItem(val) {
				hlhttp.put({
					url: 'configure/annual_day_config',
					data: {
						"dict_name": val[0].dictName,
						"dict_value": val[0].dictValue,
						"dict_property": val[0].dictProperty,
					},
					success: function () {
						hl.toast('设置成功')
					}
				})
			},
			//按自然月接口获取
			getData() {
				hlhttp.get({
					url: 'configure/dict',
					data: {
						module_code: 'CIWU',
						config_name: 'CW_RENT_CALCULATE_PERIOD_TYPE_CONFIG',
					},
					success: (res) => {
						this.selectedData = [res[0].dictValue]
					}
				})
			},
			entryBut() {
				this.isEntry = !this.isEntry
			},
			// 获取月租金折扣列表
			getYZJlist() {
				let data = {
					module_code: 'CIWU',
					config_name: 'CW_RENT_DISCOUNT_TYPE',
				}
				hlhttp.get({
					url: 'configure/dict',
					data: data,
					success: res => {
						res.map(item => {
							item.code = item.dictCode,
								item.name = item.dictName
						})
						this.yzjList = res
					}
				})
			},
			// 获取月租金配置
			getYZJconfig() {
				let data = {
					module_code: 'CIWU',
					config_name: 'CW_RENT_DISCOUNT_TYPE_CONFIG',
				}
				hlhttp.get({
					url: 'configure/dict',
					data: data,
					success: res => {
						this.selectedYZJ = [res[0].dictValue]
						this.selectYZJObj = res[0]
					}
				})
			},
			// 设置月租金选项
			setSelectYZJ(val) {
				let data = {
					module_code: 'CIWU',
					config_name: 'CW_RENT_DISCOUNT_TYPE_CONFIG',
					dict_code: this.selectYZJObj.dictCode,
					dict_name: val[0].dictName,
					dict_value: val[0].dictCode,
					dict_display_name: this.selectYZJObj.dictDisplayName || '#',
					dict_property: this.selectYZJObj.dictProperty || '#',
					default_flag: this.selectYZJObj.defaultFlag || '#',
					config_type: this.selectYZJObj.configType || '#',
				}
				hlhttp.put({
					url: 'configure/tenant_dict_config',
					data: data,
					success: res => {}
				})
			},

		},
		mounted() {
			this.getRent()
			this.getData()
			// this.geTintentBpmConfig()
			this.getTintentConfig()
			this.selectTintentConfig()
			this.getYZJlist()
		},
	})
}())